package com.itypd.basic;

import com.itypd.pojo.SynchronizedTestObj;

/*
 * @Description:
 * @Athor: GongMingwei
 * @version: v1.0
 */
public class SynchronizedTest {
    public static void main(String[] args) {
        SynchronizedTestObj testObj = new SynchronizedTestObj();
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                while(testObj.getI() < 1000){
                    System.out.print(Thread.currentThread()+" ");
                    testObj.increase();
                }
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                while(testObj.getI() < 1000){
                    System.out.print(Thread.currentThread()+" ");
                    testObj.increase();
                }
            }
        });
        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                while(testObj.getI() < 1000){
                    System.out.print(Thread.currentThread()+" ");
                    testObj.increase();
                }
            }
        });
        Thread t4 = new Thread(new Runnable() {
            @Override
            public void run() {
                while(testObj.getI() < 1000){
                    System.out.print(Thread.currentThread()+" ");
                    testObj.increase();
                }
            }
        });
        Thread t5 = new Thread(new Runnable() {
            @Override
            public void run() {
                while(testObj.getI() < 1000){
                    System.out.print(Thread.currentThread()+" ");
                    testObj.increase();
                }
            }
        });
        t1.start();
        t2.start();
        t3.start();
        t4.start();
        t5.start();
    }
}
